package com.dream21th.admin.controller;

import com.dream21th.admin.entity.SysUserEntity;
import com.dream21th.admin.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;

@Component
public class BaseUserController {

    @Autowired
    private SysUserService sysUserService;

    public SysUserEntity loginUser(Authentication authentication){
        String username = (String)authentication.getPrincipal();
        SysUserEntity sysUserEntity = sysUserService.queryByUserName(username);
        return sysUserEntity;
    }

    public Long loginUserId(Authentication authentication){
        return loginUser(authentication).getUserId();
    }
}
